/*
 * ServerBean.java
 *
 * Created on April 21, 2007, 2:13 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package info.decamps.m2settings.beans;

import info.decamps.m2settings.model.Server;
import info.decamps.m2settings.model.Settings;
import org.omg.PortableInterceptor.SUCCESSFUL;

/**
 * This class represents a Server.
 * It extends Castor generated class to handle Unix permissions better.
 * Element  	Description
 * username 	The username used to authenticate.
 * password 	The password used in conjunction with the username to authenticate.
 * privateKey 	The private key location used to authenticate.
 * passphrase 	The passphrase used in conjunction with the privateKey to authenticate.
 * filePermissions 	The permissions for files when they are created.
 * directoryPermissions 	The permissions for directories when they are created.
 * configuration 	Extra configuration for the transport layer.
 * id 	No description.
 * @author regis
 */
public class MyServer{
    private Permissions filePermissions;
    private Permissions directoryPermissions;
    private Server server;
    
    public MyServer() {
        this(new Server());
        directoryPermissions.setUserExec(true);
        directoryPermissions.setGroupExec(true);
    }
    public MyServer(info.decamps.m2settings.model.Server s) {
        filePermissions=new Permissions(s.getFilePermissions());
        directoryPermissions=new Permissions(s.getDirectoryPermissions());
        server=s;
    }
    
    public void setFilePermissions(Permissions filePermissions) {
        this.filePermissions=filePermissions;
        server.setFilePermissions(filePermissions.toString());
    }
    public void setDirectoryPermissions(Permissions directoryPermissions) {
        this.directoryPermissions=directoryPermissions;
        server.setDirectoryPermissions(directoryPermissions.toString());
    }
    public boolean isFileUserRead() {
        return filePermissions.isUserRead();
    }
    public boolean isFileUserWrite() {
        return filePermissions.isUserWrite();
    }
    public boolean isFileUserExec() {
        return filePermissions.isUserExec();
    }
    public boolean isDirUserRead() {
        return directoryPermissions.isUserRead();
    }
    public boolean isDirUserWrite() {
        return directoryPermissions.isUserWrite();
    }
    public boolean isDirUserExec() {
        return directoryPermissions.isUserExec();
    }
    public boolean isFileGroupRead() {
        return filePermissions.isGroupRead();
    }
    public boolean isFileGroupWrite() {
        return filePermissions.isGroupWrite();
    }
    public boolean isFileGroupExec() {
        return filePermissions.isGroupExec();
    }
    public boolean isDirGroupRead() {
        return directoryPermissions.isGroupRead();
    }
    public boolean isDirGroupWrite() {
        return directoryPermissions.isGroupWrite();
    }
    public boolean isDirGroupExec() {
        return directoryPermissions.isGroupExec();
    }
    public boolean isFileOtherRead() {
        return filePermissions.isOtherRead();
    }
    public boolean isFileOtherWrite() {
        return filePermissions.isOtherWrite();
    }
    public boolean isFileOtherExec() {
        return filePermissions.isOtherExec();
    }
    public boolean isDirOtherRead() {
        return directoryPermissions.isOtherRead();
    }
    public boolean isDirOtherWrite() {
        return directoryPermissions.isOtherWrite();
    }
    public boolean isDirOtherExec() {
        return directoryPermissions.isOtherExec();
    }
    
    public void setId(String id) {
        server.setId(id);
    }
    
    public void setUsername(String username) {
        server.setUsername(username);
    }
    
    public void setPassword(String password) {
        server.setPassword(password);
    }

    public void setPrivateKey(String privateKey) {
        server.setPrivateKey(privateKey);
    }

    public void setPassphrase(String passphrase) {
        server.setPassphrase(passphrase);
    }

    public Server getServer() {
        return server;
    }

    public String getId() {
        return server.getId();
    }

    public String getUsername() {
        return server.getUsername();
    }

    public String getPassword() {
        return server.getPassword();
    }

    public String getPrivatekey() {
        return server.getPrivateKey();
    }

    public String getPassphrase() {
        return server.getPassphrase();
    }

    public void setPassword(char[] c) {
        setPassword(new String(c));
    }

    public void setPassphrase(char[] c) {
        setPassphrase(new String(c));
    }
    
}